package com.wuercloud.swagger;
/*package com.wuercloud.swagger;


import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HttpContext;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;

import java.net.*;
import java.util.*;

*//**
 * Created by JiangWL on 2017/4/21.
 *//*
@Component
public class WawaRabbitClient {
    private RestTemplate restClientTemplate;
    private URI rootUri;

    public WawaRabbitClient(String url, String username, String password) throws MalformedURLException, URISyntaxException {
        this(new URL(url), username, password);
    }

    public WawaRabbitClient(URL url, String username, String password) throws MalformedURLException, URISyntaxException {
        this.rootUri = url.toURI();
        this.restClientTemplate = new RestTemplate(this.getRequestFactory(url, username, password));
        this.restClientTemplate.setMessageConverters(this.getMessageConverters());
    }
    private List<HttpMessageConverter<?>> getMessageConverters() {
        List<HttpMessageConverter<?>> xs = new ArrayList();
        Jackson2ObjectMapperBuilder bldr = Jackson2ObjectMapperBuilder.json().serializationInclusion(JsonInclude.Include.NON_NULL);
        xs.add(new MappingJackson2HttpMessageConverter(bldr.build()));
        return xs;
    }

    private CredentialsProvider getCredentialsProvider(URL url, String username, String password) {
        CredentialsProvider cp = new BasicCredentialsProvider();
        cp.setCredentials(new AuthScope(AuthScope.ANY_HOST, -1), new UsernamePasswordCredentials(username, password));
        return cp;
    }

    private HttpComponentsClientHttpRequestFactory getRequestFactory(URL url, String username, String password) throws MalformedURLException {
        HttpClientBuilder bldr = HttpClientBuilder.create().setDefaultCredentialsProvider(this.getCredentialsProvider(url, username, password));
        bldr.setDefaultHeaders(Arrays.asList(new BasicHeader[]{new BasicHeader("Content-Type", "application/json")}));
        HttpClient httpClient = bldr.build();
        AuthCache authCache = new BasicAuthCache();
        BasicScheme basicScheme = new BasicScheme();
        authCache.put(new HttpHost(this.rootUri.getHost(), this.rootUri.getPort(), this.rootUri.getScheme()), basicScheme);
        final HttpClientContext ctx = HttpClientContext.create();
        ctx.setAuthCache(authCache);
        return new HttpComponentsClientHttpRequestFactory(httpClient) {
            protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
                return ctx;
            }
        };
    }

    public void unBind(String vhost, String queue, String exchange, String routingKey){
        if(vhost != null && !vhost.isEmpty()) {
            if(queue != null && !queue.isEmpty()) {
                if(exchange != null && !exchange.isEmpty()) {
                 
                    String apiUrl = rootUri.toString() + "bindings/" + this.encodePathSegment(vhost) + "/e/" + this.encodePathSegment(exchange) + "/q/" + this.encodePathSegment(queue) + "/"+this.encodePathSegment(routingKey);
                    URI uri = this.uriWithPath(apiUrl);
                    this.deleteIgnoring404(uri);
                    //this.restClientTemplate.delete(url.concat(apiUrl), body);
                } else {
                    throw new IllegalArgumentException("exchange cannot be null or blank");
                }
            } else {
                throw new IllegalArgumentException("queue cannot be null or blank");
            }
        } else {
            throw new IllegalArgumentException("vhost cannot be null or blank");
        }
    }
    private void deleteIgnoring404(URI uri) {
        try {
            this.restClientTemplate.delete(uri);
        } catch (HttpClientErrorException var3) {
            if(var3.getStatusCode() != HttpStatus.NOT_FOUND) {
                throw var3;
            }
        }

    }

    private URI uriWithPath(String path) {
        return this.rootUri.resolve(path);
    }

    private String encodePathSegment(String vhost) {
        return URLEncoder.encode(vhost);
    }
}
*/